percent-encode npm releaser names in Maintainer changes section#14638
percent-encode npm releaser names in Maintainer changes section#14638v-HaripriyaC wants to merge 11 commits intomainfrom
Conversation
0bd786e to
175a5eb
Compare
41dbe34 to
9476b45
Compare
9476b45 to
b72ea4c
Compare
|
@kbukum1 none of this PR checks failing are related to this PR. below is the info
|
|
these are pre-existing smoke flakiness failures unrelated to this change |
There was a problem hiding this comment.
Pull request overview
Fixes broken Markdown links in the Maintainer changes section for npm dependencies when the npm releaser name contains spaces or other URL-unsafe characters by percent-encoding the releaser name before building the npmjs.com profile URL.
Changes:
- Add a helper to percent-encode npm releaser names used in npm profile links.
- Add/extend spec coverage with a realistic npm registry response fixture to verify encoding behavior.
- Adjust registry URL handling/spec around trailing slashes.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| npm_and_yarn/lib/dependabot/npm_and_yarn/metadata_finder.rb | Encode npm releaser in maintainer profile URLs; adjust registry URL normalization logic. |
| npm_and_yarn/spec/dependabot/npm_and_yarn/metadata_finder_spec.rb | Add coverage for maintainer link encoding; update registry URL trailing-slash scenario. |
| npm_and_yarn/spec/fixtures/npm_responses/npm-package-json-lint.json | Add fixture with a releaser name containing spaces to reproduce/verify the issue. |
|
@kbukum1 The failing smoke e2e jobs (smoke-npm.yaml, smoke-npm-yarn.yaml, smoke-npm-version-multidir.yaml) are pre-existing failures on main caused by live npm registry version drift (fixture snapshots are stale). These are not related to the changes in this PR. Verified by checking the same jobs fail on main at commit 20fe02a. |
2b0b698 to
de9eae7
Compare
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…4711) * Initial plan * Fix percent-encoding issues in npm_and_yarn and bun MetadataFinders Agent-Logs-Url: https://github.com/dependabot/dependabot-core/sessions/13261c22-8e0e-42fe-a06d-e8a7c3b7ad76 Co-authored-by: kbukum1 <171620528+kbukum1@users.noreply.github.com> * Address code review: remove private method test from bun spec Agent-Logs-Url: https://github.com/dependabot/dependabot-core/sessions/13261c22-8e0e-42fe-a06d-e8a7c3b7ad76 Co-authored-by: kbukum1 <171620528+kbukum1@users.noreply.github.com> * parametric tests added, fixed some edge case as well * ade sure the fix is for bun * added some more fixes * added small fixe --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: kbukum1 <171620528+kbukum1@users.noreply.github.com> Co-authored-by: v-HaripriyaC <v-haripriyac@microsoft.com>
de9eae7 to
3d4a41a
Compare
What are you trying to accomplish?
Fixes #14595 — The Maintainer changes section in Dependabot PR bodies for npm dependencies can generate a broken Markdown link if the npm releaser name contains spaces (or other URL-unsafe characters), such as in the case of "GitHub Actions".
Previously, the link for the releaser in the PR body was constructed like:
Markdown
This version was pushed to npm by [GitHub Actions](https://www.npmjs.com/~GitHub Actions), ...
This link is broken due to the unencoded space in the URL, which is invalid in Markdown and web standards.
What changed?
npm_and_yarn/lib/dependabot/npm_and_yarn/metadata_finder.rb: The maintainer_changes method now uses a new encode_npm_releaser helper. This percent-encodes the npm releaser name according to RFC 3986 before interpolating it into the npmjs.com profile URL — e.g., "GitHub Actions" becomes "GitHub%20Actions" in the URL, producing a valid Markdown link. The helper short-circuits for normal usernames (all safe chars) as an optimization.
Spec coverage: Added tests using a realistic fixture to confirm spaces and other special characters are encoded, and the Markdown link is syntactically valid.
How will you know you've accomplished your goal?
New and existing specs pass, explicitly verifying %20 encoding for spaces in npm releaser profile links.
In real Dependabot PRs (e.g., npm-package-json-lint 9.0.0 → 10.0.0), the Maintainer changes section now shows a correctly formed Markdown link. Note: the target npm profile may still 404 for bot releasers — this is upstream behavior outside Dependabot's control.
Anything to highlight for reviewers?
Encoding leverages RFC 3986 compliance via Ruby stdlib. Display text is intentionally left unencoded.
The npmjs.com URL may 404 for certain bot releasers — this fix only ensures the Markdown and URI are syntactically valid.
Checklist
Tests and linters pass
New tests added for the space-in-releaser-name scenario
Clear commit messages
Detailed PR description provided
Code is documented and easy to understand